package band.wukong.practice.java.core.topic.concurrency.thread.runnablevsthread;

/**
 * @author wukong(wukonggg@139.com)
 */
public class ThreadDemo {

    public static void main(String[] args) {
        System.out.println("["+ Thread.currentThread().getName() +"] Main");
        new MyThread().start();
        new MyThread().start();
        new MyThread().start();
    }
}

class MyThread extends Thread {

    private int ticket = 5;

    public void run() {
        for (int i = 0; i < 10; i++) {
            if (ticket > 0) {
                System.out.println("["+ Thread.currentThread().getName() +"] ticket = " + ticket--);
            }
        }
    }
}

